procedure CheckForStack; begin if nPics=0 then begin PutMessage('This macro requires a stack.'); exit; end; if nSlices=0 then begin PutMessage('This window is not a stack.'); exit end; end; procedure CheckForSelection; var x1,y1,x2,y2,LineWidth:integer; begin GetRoi(RoiLeft,RoiTop,RoiWidth,RoiHeight); GetLine(x1,y1,x2,y2,LineWidth); if (RoiWidth=0) or (x1>=0) then begin PutMessage('Please make a rectangular selection.'); exit; end; end; procedure ResliceSignaMRI(horizontal,OptionKey:boolean); var stack1,stack2,width,height:integer; RoiLeft,RoiTop,RoiWidth,RoiHeight,max:integer; loc,PixelSpacing:real; InputSpacing,OutputSpacing:real; {mm} scale:real; {pixels/mm} FirstTime:boolean; begin scale:=1.0666; {Assumes 256x256 slices and 240mm field of view} RequiresVersion(1.45); CheckForStack; CheckForSelection; SaveState; SetScale(scale,'mm'); SetBackground(0); SetBackground(255); stack1:=PicNumber; InputSpacing:=GetSliceSpacing/scale; if InputSpacing<=0 then InputSpacing:=1.5; InputSpacing:=GetNumber('Input Slice Spacing(mm):',InputSpacing); SetSliceSpacing(InputSpacing*scale); OutputSpacing:=InputSpacing; OutputSpacing:=GetNumber('Output Slice Spacing (mm):', OutputSpacing); PixelSpacing:=OutputSpacing*scale; FirstTime:=true; GetRoi(RoiLeft,RoiTop,RoiWidth,RoiHeight); if horizontal then begin loc:=RoiTop+PixelSpacing; max:=RoiTop+RoiHeight; end else begin loc:=RoiLeft+PixelSpacing; max:=RoiLeft+RoiWidth; end; while locfirst then AddSlice; n:=n+1; Paste; end; end; macro 'Sagitals to CoronalsÉ'; begin ResliceSignaMRI(false,true) end; macro 'Sagitals to AxialsÉ'; begin ResliceSignaMRI(true,true) end; macro 'Coronals to SagitalsÉ'; begin ResliceSignaMRI(false,true) end;